/*============================================================================*/

* Do: Regressions Part 2 - ENAHO
* Last update: 09.05.2023

/*============================================================================*/

* SECTION: FOLDERS
* ==============================================================================

*------------------------ SUBFOLDERS (DO NOT CHANGE)
gl in "$root/Final"
gl analysis "$root/Analysis"

* ==============================================================================
* SECTION: REGRESSIONS
* ==============================================================================

cap log close
log using "regressions_part2LMextend", replace

use "$in/data_regressions_enaho", clear

recode occupation 0=., gen(occ1)
replace occ1 = 12 - occ1

recode education_group 4=3, gen(ed3)

xtset, clear

* Outcomes

local outcome employment_status formalemploy occ1 lnwage1 lnhhinc lnhhexp 

* Covariates

local indvchar c.age##c.age i.marital_status hhsize  

local iv c.logsharevz07#(i2015.year i2016.year i2017.year i2018.year i2019.year i2020.year)

*------------------------ REGRESSIONS


forv i = 0/2 {
forv j = 1/3 {

if `i'~=2 {
local sex "if female==`i' & ed3==`j'"
}

else {
local sex "female if ed3==`j'"
}

if `j'==3 {
local ed "i4.education_group"
}

else {
local ed ""
}

foreach y of local outcome {

		if "`y'" == "employment_status" { 
		local ra replace 
		}
	
		else { 
		local ra append 
		}

		ivreghdfe `y' (logsharevz=`iv') `indvchar' `ed' `sex', cluster(province_id) absorb(i.month##i.year province_id c.time#i.province_id)
		
			outreg2 using "$analysis/part2_LMext`i'`j'.xls", dec(3) nocons `ra' label ///
				addtext(Model, IV, Region FE, Yes, Year FE, Yes, District FE, Yes, RegionXTime trends, Yes) 

}
}
}


log close

